<?php
include_once 'module/conn.php';
include_once 'common/tools.php';

//启用一个带有ob_gzip压缩机的工作台
ob_start('ob_gzip');

$matchId = $_GET["matchId"];
@ $matchOptaId = $_GET["matchOptaId"];
@ $scoreId = $_GET["scoreId"];
@ $userId = $_GET["id"];
@ $userIp = $_SERVER["REMOTE_ADDR"];
@ $userMac = $_GET["mac"];

$config = require 'conf/config.ini.php'; //加载公用config.ini.php
$conn = mysql_connect($config["DB_HOST"], $config["DB_USER"], $config["DB_PWD"]);
mysql_select_db($config["DB_NAME"], $conn);
mysql_query("SET NAMES utf8");

if ($scoreId == "") {
	$sql = "select * from live_score where (matchId = '" . $matchOptaId . "' or matchId = '" . $matchId . "') order by scoreId desc";
} else {
	$sql = "select * from live_score where (matchId = '" . $matchOptaId . "' or matchId = '" . $matchId . "') and scoreId > '" . $scoreId . "' order by scoreId desc";
}

$matchList = mysql_query($sql, $conn);
if (mysql_num_rows($matchList) > 0) {
	while ($match = mysql_fetch_object($matchList)) {
		$matchArray[] = $match;
	}
	//echo '{"sql":"' . $sql . '","result":"Y","results":' . json_encode($matchArray) . '}';
	echo '{"result":"Y","results":' . json_encode($matchArray) . '}';
} else {
	//echo '{"sql":"' . $sql . '","result":"N"}';
	echo '{"result":"N"}';
}

//输出压缩成果
ob_end_flush();
?>